import java.util.Scanner;

public class Login {
    private static String name = "lisi";
    private static String password = "12345";
    public void login(String name,String password) throws NameException,PasswordException {
        if (!this.name.equals(name)) {
            throw new NameException("用户名错误，发生异常：" + name);
        }

        if (!this.password.equals(password)) {
            throw new PasswordException("密码错误，发生异常：" + password);
        }
        System.out.println("登录成功");
    }
    public static void main(String[] args) {
        Login login1 = new Login();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的用户名：");
        String name = scanner.next();
        System.out.println("请输入你的密码：");
        String password = scanner.next();
        try {
            login1.login(name,password);
        }
        catch (NameException e){
            e.printStackTrace();
        }
        catch (PasswordException e){
            e.printStackTrace();
        }
    }
}